package p270jp;

import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Objects;
import p244ip.C3839e0;
import p244ip.CallAdapter;
import p244ip.Response;
import p244ip.Retrofit;
import p593wc.AbstractC6902j;
import p593wc.AbstractC6904o;
import p593wc.Completable;
import p593wc.Flowable;
import p593wc.Maybe;
import p593wc.Single;

/* renamed from: jp.g */
/* loaded from: classes2.dex */
public final class RxJava2CallAdapterFactory extends CallAdapter.AbstractC3833a {

    /* renamed from: a */
    public final AbstractC6904o f18286a;

    /* renamed from: b */
    public final boolean f18287b;

    public RxJava2CallAdapterFactory(AbstractC6904o oVar, boolean z) {
        this.f18286a = oVar;
        this.f18287b = z;
    }

    /* renamed from: b */
    public static RxJava2CallAdapterFactory m4866b(AbstractC6904o oVar) {
        Objects.requireNonNull(oVar, "scheduler == null");
        return new RxJava2CallAdapterFactory(oVar, false);
    }

    @Override // p244ip.CallAdapter.AbstractC3833a
    /* renamed from: a */
    public CallAdapter<?, ?> mo4867a(Type type, Annotation[] annotationArr, Retrofit a0Var) {
        boolean z;
        boolean z2;
        Type type2;
        Class<?> f = C3839e0.m5122f(type);
        if (f == Completable.class) {
            return new RxJava2CallAdapter(Void.class, this.f18286a, this.f18287b, false, true, false, false, false, true);
        }
        boolean z3 = f == Flowable.class;
        boolean z4 = f == Single.class;
        boolean z5 = f == Maybe.class;
        if (f != AbstractC6902j.class && !z3 && !z4 && !z5) {
            return null;
        }
        if (!(type instanceof ParameterizedType)) {
            String str = !z3 ? !z4 ? z5 ? "Maybe" : "Observable" : "Single" : "Flowable";
            throw new IllegalStateException(str + " return type must be parameterized as " + str + "<Foo> or " + str + "<? extends Foo>");
        }
        Type e = C3839e0.m5123e(0, (ParameterizedType) type);
        Class<?> f2 = C3839e0.m5122f(e);
        if (f2 == Response.class) {
            if (e instanceof ParameterizedType) {
                type2 = C3839e0.m5123e(0, (ParameterizedType) e);
                z2 = false;
                z = false;
            } else {
                throw new IllegalStateException("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
            }
        } else if (f2 != Result.class) {
            type2 = e;
            z = true;
            z2 = false;
        } else if (e instanceof ParameterizedType) {
            type2 = C3839e0.m5123e(0, (ParameterizedType) e);
            z2 = true;
            z = false;
        } else {
            throw new IllegalStateException("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
        }
        return new RxJava2CallAdapter(type2, this.f18286a, this.f18287b, z2, z, z3, z4, z5, false);
    }
}
